package com.ruoyi.system.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ZhwyAdvancedepositMapper;
import com.ruoyi.system.domain.ZhwyAdvancedeposit;
import com.ruoyi.system.service.IZhwyAdvancedepositService;

/**
 * 预存款管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-05-07
 */
@Service
public class ZhwyAdvancedepositServiceImpl implements IZhwyAdvancedepositService 
{
    @Autowired
    private ZhwyAdvancedepositMapper zhwyAdvancedepositMapper;

    /**
     * 查询预存款管理
     * 
     * @param id 预存款管理主键
     * @return 预存款管理
     */
    @Override
    public ZhwyAdvancedeposit selectZhwyAdvancedepositById(Long id)
    {
        return zhwyAdvancedepositMapper.selectZhwyAdvancedepositById(id);
    }

    @Override
    public List<ZhwyAdvancedeposit> selectGroupByShopsId(ZhwyAdvancedeposit zhwyAdvancedeposit) {
        return zhwyAdvancedepositMapper.selectByShopsId(zhwyAdvancedeposit);
    }

    /**
     * 查询预存款管理列表
     * 
     * @param zhwyAdvancedeposit 预存款管理
     * @return 预存款管理
     */
    @Override
    public List<ZhwyAdvancedeposit> selectZhwyAdvancedepositList(ZhwyAdvancedeposit zhwyAdvancedeposit)
    {
        return zhwyAdvancedepositMapper.selectZhwyAdvancedepositList(zhwyAdvancedeposit);
    }

    /**
     * 新增预存款管理
     * 
     * @param zhwyAdvancedeposit 预存款管理
     * @return 结果
     */
    @Override
    public int insertZhwyAdvancedeposit(ZhwyAdvancedeposit zhwyAdvancedeposit)
    {
//        生成订单号
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String currentDate = sdf.format(new Date());
        String uuid = UUID.randomUUID().toString().replace("-", "");
        String combined = currentDate + "_" + uuid;
        zhwyAdvancedeposit.setPayNo(combined);

        return zhwyAdvancedepositMapper.insertZhwyAdvancedeposit(zhwyAdvancedeposit);
    }

    /**
     * 修改预存款管理
     * 
     * @param zhwyAdvancedeposit 预存款管理
     * @return 结果
     */
    @Override
    public int updateZhwyAdvancedeposit(ZhwyAdvancedeposit zhwyAdvancedeposit)
    {
        return zhwyAdvancedepositMapper.updateZhwyAdvancedeposit(zhwyAdvancedeposit);
    }

    /**
     * 批量删除预存款管理
     * 
     * @param ids 需要删除的预存款管理主键
     * @return 结果
     */
    @Override
    public int deleteZhwyAdvancedepositByIds(Long[] ids)
    {
        return zhwyAdvancedepositMapper.deleteZhwyAdvancedepositByIds(ids);
    }

    /**
     * 删除预存款管理信息
     * 
     * @param id 预存款管理主键
     * @return 结果
     */
    @Override
    public int deleteZhwyAdvancedepositById(Long id)
    {
        return zhwyAdvancedepositMapper.deleteZhwyAdvancedepositById(id);
    }
}
